import tkinter as tk


# 2021-06-21 13:14 by 炸天帮成员
# 关于radioButton的操作

class CreateNewFrame:
    def __init__(self, root_id):
        self.master_window_0 = root_id

        self.frame = tk.Frame(self.master_window_0)
        self.frame.pack()

        self.RBttn_Var1 = tk.IntVar()
        self.RBttn_1 = tk.Radiobutton(self.frame, text="Option1", variable=self.RBttn_Var1, value=1,
                                      command=self.find_which_rbutton_selected)
        self.RBttn_1.pack()

        self.RBttn_2 = tk.Radiobutton(self.frame, text="Option2", variable=self.RBttn_Var1, value=2,
                                      command=self.find_which_rbutton_selected)
        self.RBttn_2.pack()

    def find_which_rbutton_selected(self):
        print("当前为 ：", self.RBttn_Var1.get())


if __name__ == "__main__":
    root = tk.Tk()
    root.geometry("400x400")
    frame_in_window_0 = CreateNewFrame(root)

    root.mainloop()  # 这句话别忘记，否则运行不会成功，虽然在IDLE中可以运行。
